<?php
	/**
	 * 获取今日巅峰榜
	 */
    class Integrationboard extends APIBase {
		
		public $tag = "Integrationboard";
    	public $isLogin = false;
		
		public function before() {
			$this->initCacheRedis();
			return true;
		}
		public function logic() {
			//$ann = $this->cache_redis->hMGet("ha:*", array("id","title","content","image_url"));
			//$userid = (int) $this->uid;
			$userid = $this->param['playerID'];
			$billboard = $this->cache_redis->keys("hIntegrationboard:*");
			$count = count($billboard);
			$result = array();
			$data = array();
			if ($count) {
				//获取个人数据与排名前三十
				for($i=0;$i<$count;$i++){					
				 $list= $this->cache_redis->hGetAll("hIntegrationboard:".$i);
				 if($list['user_id']==$userid){
					$data = array('point'=>$list['point'],'rank'=>$list['num']); 
				 }
				 if($i<=30){
					$result[] = $list; 
				 }
				}
				
				$selfdata = array();
                if(empty($data)){
					$selfdata[]= array('point'=>'0','rank'=>'未入围');
				}elseif($data['rank']>30){
					$selfdata[]= array('point'=>$data['point'],'rank'=>'未入围');
				}elseif($data['rank']<=30){
					$selfdata[]= array('point'=>$data['point'],'rank'=>$data['rank']);
				}
				$this->returnData(array_merge($result,$selfdata));
			} else {
				$this->returnError(301,"对不起，暂无今日巅峰排行榜！");
			}

		}
		
        public function after() {
			$this->deinitCacheRedis();
		}
    }
?>
